package com.tech.platform.cms.logger.listener;

import cn.hutool.json.JSONUtil;
import com.tech.platform.cms.logger.event.ApiLogEvent;
import com.tech.platform.cms.logger.model.ApiLogModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author shengqiang.wu
 * @date 2020/3/24/024 16:25
 * @desc
 */
@Slf4j
@Component
public class ApiLogListener {

    @Async
    @EventListener(ApiLogEvent.class)
    public void addApiLog(ApiLogEvent apiLogEvent){
        ApiLogModel apiLogModel = apiLogEvent.getSource();
        log.info(JSONUtil.toJsonPrettyStr(apiLogModel));
    }
}
